#!/bin/sh

reduces=20

mt=20
rt=10

if [ -d /etc/hadoop/conf.cloudera.yarn1 ]; then
    echo "Cloudera hadoop"
    export HADOOP_CONF_DIR=/etc/hadoop/conf.cloudera.yarn1
    hdfs dfs -touchz data.txt
    hdfs dfs -rm -r -skipTrash sleep_result
elif [ -d /opt/mapr ]; then
    echo "MapR hadoop, not supported"
    exit 1
else
    echo "HortonWorks hadoop"

    hdfs dfs -touchz data.txt
    hdfs dfs -rmr -skipTrash sleep_result
fi

STREAMJAR=/usr/lib/hadoop-mapreduce/hadoop-streaming-2.*.jar

yarn jar $STREAMJAR \
    -D mapreduce.job.name='Sleeping test' \
    -D mapreduce.map.speculative=true \
    -D mapreduce.reduce.speculative=true \
    -numReduceTasks $reduces \
    -mapper "sleep $mt" \
    -reducer "sleep $rt" \
    -input data.txt -output sleep_result


